package com.ad.pet.ui;

import android.app.Dialog;
import android.content.Context;
import android.support.annotation.NonNull;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;

import com.ad.pet.R;

/**
 * Created by liuyixiang on 2019/9/14.
 */

public class ShopFirstToCartDialog extends Dialog {
    private int screenWidth;
    public ShopFirstToCartDialog(@NonNull Context context) {
        super(context);
    }

    public ShopFirstToCartDialog(Context context, int themeResId) {
        super(context, themeResId);
        screenWidth = context.getResources().getDisplayMetrics().widthPixels;
        View view = LayoutInflater.from(context).inflate(R.layout.layout_chose_pay_or_shoping_first_dialog,null);
        view.findViewById(R.id.iv_close_paydialog).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                dismiss();
            }
        });
        setContentView(view);

    }

    @Override
    public void show() {
        super.show();
        Window window = this.getWindow();
        WindowManager.LayoutParams lp = window.getAttributes();
        lp.width = (screenWidth *  8/ 10); // 设置宽度
        this.getWindow().setAttributes(lp);
        window.setGravity(Gravity.CENTER);
    }
}
